package com.cjm.one.custom.admin.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.common.result.Result;
import com.cjm.one.common.utils.AuthSysUserContextHolder;
import com.cjm.one.custom.service.CustomSignInService;
import com.cjm.one.model.custom.entity.CustomSignIn;
import com.cjm.one.model.system.entity.SysUserInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@Tag(name = "5-签到记录")
@RequestMapping("/admin/custom/signIn")
public class CustomSignInController {

    @Resource
    private CustomSignInService customSignInService;

    @GetMapping("/list")
    @Operation(summary = "用户获取签到记录列表")
    public Result<Page<CustomSignIn>> list(@RequestParam Integer current, @RequestParam Integer size) {
        SysUserInfo authContextSysUser = AuthSysUserContextHolder.getAuthContextSysUser();
        Long userId = authContextSysUser.getId();
        return Result.ok(customSignInService.getList(current, size, userId)) ;
    }

    @PostMapping
    @Operation(summary = "用户签到")
    public Result<Boolean> signIn() {
        SysUserInfo authContextSysUser = AuthSysUserContextHolder.getAuthContextSysUser();
        Long userId = authContextSysUser.getId();
        return Result.ok(customSignInService.signIn(userId)) ;
    }

}
